import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * @author ShenTuZhiGang
 * @version 1.0.0
 * @email 1600337300@qq.com
 * @date 2021-09-18 18:03
 */
public class ExamNetEase2021091804 {
    private static int n;
    private static int a;
    private static int b;
    private static int[][] ans;
    private static boolean flag = false;
    private static int[][] pos = new int[2][2];
    private static char[][] map;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        a = scanner.nextInt();
        b = scanner.nextInt();
        map = new char[n][n];
        ans = new int[n][n];
        pos[0][0] = -1;
        pos[0][1] = -1;
        pos[1][0] = -1;
        pos[1][1] = -1;
        int p = 0;
        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            map[i] = scanner.nextLine().toCharArray();
            for (int j = 0; j < n; j++) {
                if (map[i][j] == '*') {
                    pos[p][0] = i;
                    pos[p][1] = j;
                    flag = true;
                }
                ans[i][j] = Integer.MAX_VALUE;
            }
        }
        PriorityQueue<Node> q = new PriorityQueue<>(new Comparator<Node>() {
            @Override
            public int compare(Node o1, Node o2) {
                return o1.count - o2.count;
            }
        });
        Node node = new Node();
        node.x = 0;
        node.y = 0;
        node.count = 0;
        q.add(node);
        while (q.size() > 0) {
            node = q.poll();
            if (node.x >= n || node.y >= n || node.x < 0 || node.y < 0 || node.count > ans[n - 1][n - 1]) {
                continue;
            }
            if (ans[node.x][node.y] > node.count) {
                ans[node.x][node.y] = node.count;
            } else {
                return;
            }
            int c1 = 0;
            if (map[node.x][node.y] == '#') {
                c1 = a;
            } else if (map[node.x][node.y] == '*') {
                Node node1 = new Node();
                if (node.x == pos[0][0] && node.y == pos[0][1]) {
                    node1.x = pos[1][0];
                    node1.y = pos[1][1];
                } else {
                    node1.x = pos[0][0];
                    node1.y = pos[0][1];
                }
                node1.count = node.count + b;
                q.add(node1);
            }
            dfs(q, node.x + 1, node.y, node.count + c1);
            dfs(q, node.x, node.y + 1, node.count + c1);
            dfs(q, node.x - 1, node.y, node.count + c1);
            dfs(q, node.x, node.y - 1, node.count + c1);
        }
        System.out.println(ans[n - 1][n - 1]);
    }

    public static void dfs(PriorityQueue<Node> q, int x, int y, int count) {
        Node node1 = new Node();
        node1.x = x;
        node1.y = y;
        node1.count = count;
        q.add(node1);
    }

    static class Node {
        int x;
        int y;
        int count;
    }
}